package blt.a3rd.map;

import android.util.Log;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;


import blt.app_core.api.base.CoreManager;
import blt.app_core.api.other.OutApi;

/**
 * Created by Administrator on 2016/3/16.
 */
public class MapListener implements BDLocationListener {
    public static final String MAP_CALL_BACK = "map_call_back";

    private static final String TAG = MapListener.class.getSimpleName();

    private int locationCount;//定位次数，超过3次不再定位

    @Override
    public void onReceiveLocation(BDLocation l) {
        String address = null;
        locationCount++;
        if (l.getLocType() == BDLocation.TypeGpsLocation) {// GPRS定位
            address = l.getCity();
        } else if (l.getLocType() == BDLocation.TypeNetWorkLocation) {// wifi定位
            address = l.getCity();
        }
        Log.d(TAG, "address:" + l.getProvince() + l.getCity() + "  /locType:" + l.getLocType());

//        Map<String, Object> map = new HashMap<>();
//        map.put("city", address);
//        map.put("latitude", l.getLatitude());//纬度
//        map.put("longitude", l.getLongitude());//经度
        CoreManager.notifyClients(OutApi.class, OutApi.onLocation, address);

    }

    @Override
    public void onConnectHotSpotMessage(String s, int i) {

    }


}
